package com.ohxwj.modules.web.controller;

import com.ohxwj.common.utils.R;
import com.ohxwj.modules.web.entity.WebRecommendEntity;
import com.ohxwj.modules.web.service.WebRecommendService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Created by Administrator on 2018-04-17.
 */
@RestController
@RequestMapping("/web/recommend")
public class WebRecommendController extends AbstractAction {

    @Autowired
    private WebRecommendService webRecommendService;

    @RequestMapping("/list")
    public R list() {
        List<WebRecommendEntity> webRecommendEntities = webRecommendService.queryList();

        return R.ok().put("data", webRecommendEntities);
    }

    @RequestMapping("/update")
    @RequiresPermissions("web:recommend:update")
    public R update(@RequestBody WebRecommendEntity recommendEntity) {
        webRecommendService.updateRecommend(recommendEntity);

        return R.ok();
    }
}
